Skip to content

BranchHinting fuzzing: Do not remove effects when deinstrumenting#8613

Merged
kripken merged 3 commits intoWebAssembly:mainfrom
kripken:bh.fix
Apr 17, 2026
Merged

BranchHinting fuzzing: Do not remove effects when deinstrumenting#8613
kripken merged 3 commits intoWebAssembly:mainfrom
kripken:bh.fix

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Apr 16, 2026

The BranchHinting fuzzer broke after #8608, but it wasn't that PR's fault -
just that we now generate a different pattern of blocks that BranchHinting's
deinstrumentation did not handle yet. The problem was that the block with
the condition that we replace now has effects, so we can't always remove it
wholesale.

@kripken kripken requested a review from a team as a code owner April 16, 2026 19:23
@kripken kripken requested review from aheejin and removed request for a team April 16, 2026 19:23
Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered having the branch log function return the condition value so we don't need to introduce new locals to use it? That would make removing it trivial as well.

Comment on lines +205 to +210
(if
(i32.const 1)
(then
(unreachable)
)
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified to just (unreachable)?

Copy link
Copy Markdown
Member Author

@kripken kripken Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately no, then all of it would have type unreachable, which is handled in another way.

struct DeInstrumentBranchHints
: public InstrumentationProcessor<DeInstrumentBranchHints> {

template<typename T> void processCondition(T* curr) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to comment on what happens to the code that has not been swapped here due to side effects..? (It looks like logging calls are removed at the end)

By the way why do we need this replacement when we remove logging calls at the end anyway? (If it's for removing unnecessary code, wouldn't running the normal optimizer remove them?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, added a comment now, also to clarify your question. Removing the calls is necessary, while the other cleanup, that sometimes we can't do, is mainly for easy debugging.

@kripken
Copy link
Copy Markdown
Member Author

kripken commented Apr 17, 2026

@tlively

Have we considered having the branch log function return the condition value so we don't need to introduce new locals to use it? That would make removing it trivial as well.

Might be worth trying that. I don't see an obvious reason why it wouldn't work (but it's been a while since I worked on this).

@kripken kripken merged commit f051945 into WebAssembly:main Apr 17, 2026
16 checks passed
@kripken kripken deleted the bh.fix branch April 17, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants